<?php


abstract class BaseConsultaPeer {

	
	const DATABASE_NAME = 'atenea';

	
	const TABLE_NAME = 'consulta';

	
	const CLASS_DEFAULT = 'lib.model.Consulta';

	
	const NUM_COLUMNS = 12;

	
	const NUM_LAZY_LOAD_COLUMNS = 0;


	
	const ID = 'consulta.ID';

	
	const DIAGNOSTICO_ID = 'consulta.DIAGNOSTICO_ID';

	
	const FECHA = 'consulta.FECHA';

	
	const CONCLUSIONES = 'consulta.CONCLUSIONES';

	
	const HORA = 'consulta.HORA';

	
	const ESTUDIANTE_ID = 'consulta.ESTUDIANTE_ID';

	
	const ENTREVISTADO_POR_ID = 'consulta.ENTREVISTADO_POR_ID';

	
	const MOTIVO_CONSULTA_ID = 'consulta.MOTIVO_CONSULTA_ID';

	
	const TRASTORNO_ID = 'consulta.TRASTORNO_ID';

	
	const HIST_PSICOLOGICA_ID = 'consulta.HIST_PSICOLOGICA_ID';

	
	const CITA_ID = 'consulta.CITA_ID';

	
	const NUMERO_CONSULTA = 'consulta.NUMERO_CONSULTA';

	
	private static $phpNameMap = null;


	
	private static $fieldNames = array (
		BasePeer::TYPE_PHPNAME => array ('Id', 'DiagnosticoId', 'Fecha', 'Conclusiones', 'Hora', 'EstudianteId', 'EntrevistadoPorId', 'MotivoConsultaId', 'TrastornoId', 'HistPsicologicaId', 'CitaId', 'NumeroConsulta', ),
		BasePeer::TYPE_COLNAME => array (ConsultaPeer::ID, ConsultaPeer::DIAGNOSTICO_ID, ConsultaPeer::FECHA, ConsultaPeer::CONCLUSIONES, ConsultaPeer::HORA, ConsultaPeer::ESTUDIANTE_ID, ConsultaPeer::ENTREVISTADO_POR_ID, ConsultaPeer::MOTIVO_CONSULTA_ID, ConsultaPeer::TRASTORNO_ID, ConsultaPeer::HIST_PSICOLOGICA_ID, ConsultaPeer::CITA_ID, ConsultaPeer::NUMERO_CONSULTA, ),
		BasePeer::TYPE_FIELDNAME => array ('id', 'diagnostico_id', 'fecha', 'conclusiones', 'hora', 'estudiante_id', 'entrevistado_por_id', 'motivo_consulta_id', 'trastorno_id', 'hist_psicologica_id', 'cita_id', 'numero_consulta', ),
		BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, )
	);

	
	private static $fieldKeys = array (
		BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'DiagnosticoId' => 1, 'Fecha' => 2, 'Conclusiones' => 3, 'Hora' => 4, 'EstudianteId' => 5, 'EntrevistadoPorId' => 6, 'MotivoConsultaId' => 7, 'TrastornoId' => 8, 'HistPsicologicaId' => 9, 'CitaId' => 10, 'NumeroConsulta' => 11, ),
		BasePeer::TYPE_COLNAME => array (ConsultaPeer::ID => 0, ConsultaPeer::DIAGNOSTICO_ID => 1, ConsultaPeer::FECHA => 2, ConsultaPeer::CONCLUSIONES => 3, ConsultaPeer::HORA => 4, ConsultaPeer::ESTUDIANTE_ID => 5, ConsultaPeer::ENTREVISTADO_POR_ID => 6, ConsultaPeer::MOTIVO_CONSULTA_ID => 7, ConsultaPeer::TRASTORNO_ID => 8, ConsultaPeer::HIST_PSICOLOGICA_ID => 9, ConsultaPeer::CITA_ID => 10, ConsultaPeer::NUMERO_CONSULTA => 11, ),
		BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'diagnostico_id' => 1, 'fecha' => 2, 'conclusiones' => 3, 'hora' => 4, 'estudiante_id' => 5, 'entrevistado_por_id' => 6, 'motivo_consulta_id' => 7, 'trastorno_id' => 8, 'hist_psicologica_id' => 9, 'cita_id' => 10, 'numero_consulta' => 11, ),
		BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, )
	);

	
	public static function getMapBuilder()
	{
		include_once 'lib/model/map/ConsultaMapBuilder.php';
		return BasePeer::getMapBuilder('lib.model.map.ConsultaMapBuilder');
	}
	
	public static function getPhpNameMap()
	{
		if (self::$phpNameMap === null) {
			$map = ConsultaPeer::getTableMap();
			$columns = $map->getColumns();
			$nameMap = array();
			foreach ($columns as $column) {
				$nameMap[$column->getPhpName()] = $column->getColumnName();
			}
			self::$phpNameMap = $nameMap;
		}
		return self::$phpNameMap;
	}
	
	static public function translateFieldName($name, $fromType, $toType)
	{
		$toNames = self::getFieldNames($toType);
		$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
		if ($key === null) {
			throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
		}
		return $toNames[$key];
	}

	

	static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
	{
		if (!array_key_exists($type, self::$fieldNames)) {
			throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.');
		}
		return self::$fieldNames[$type];
	}

	
	public static function alias($alias, $column)
	{
		return str_replace(ConsultaPeer::TABLE_NAME.'.', $alias.'.', $column);
	}

	
	public static function addSelectColumns(Criteria $criteria)
	{

		$criteria->addSelectColumn(ConsultaPeer::ID);

		$criteria->addSelectColumn(ConsultaPeer::DIAGNOSTICO_ID);

		$criteria->addSelectColumn(ConsultaPeer::FECHA);

		$criteria->addSelectColumn(ConsultaPeer::CONCLUSIONES);

		$criteria->addSelectColumn(ConsultaPeer::HORA);

		$criteria->addSelectColumn(ConsultaPeer::ESTUDIANTE_ID);

		$criteria->addSelectColumn(ConsultaPeer::ENTREVISTADO_POR_ID);

		$criteria->addSelectColumn(ConsultaPeer::MOTIVO_CONSULTA_ID);

		$criteria->addSelectColumn(ConsultaPeer::TRASTORNO_ID);

		$criteria->addSelectColumn(ConsultaPeer::HIST_PSICOLOGICA_ID);

		$criteria->addSelectColumn(ConsultaPeer::CITA_ID);

		$criteria->addSelectColumn(ConsultaPeer::NUMERO_CONSULTA);

	}

	const COUNT = 'COUNT(consulta.ID)';
	const COUNT_DISTINCT = 'COUNT(DISTINCT consulta.ID)';

	
	public static function doCount(Criteria $criteria, $distinct = false, $con = null)
	{
				$criteria = clone $criteria;

				$criteria->clearSelectColumns()->clearOrderByColumns();
		if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
			$criteria->addSelectColumn(ConsultaPeer::COUNT_DISTINCT);
		} else {
			$criteria->addSelectColumn(ConsultaPeer::COUNT);
		}

				foreach($criteria->getGroupByColumns() as $column)
		{
			$criteria->addSelectColumn($column);
		}

		$rs = ConsultaPeer::doSelectRS($criteria, $con);
		if ($rs->next()) {
			return $rs->getInt(1);
		} else {
						return 0;
		}
	}
	
	public static function doSelectOne(Criteria $criteria, $con = null)
	{
		$critcopy = clone $criteria;
		$critcopy->setLimit(1);
		$objects = ConsultaPeer::doSelect($critcopy, $con);
		if ($objects) {
			return $objects[0];
		}
		return null;
	}
	
	public static function doSelect(Criteria $criteria, $con = null)
	{
		return ConsultaPeer::populateObjects(ConsultaPeer::doSelectRS($criteria, $con));
	}
	
	public static function doSelectRS(Criteria $criteria, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		if (!$criteria->getSelectColumns()) {
			$criteria = clone $criteria;
			ConsultaPeer::addSelectColumns($criteria);
		}

				$criteria->setDbName(self::DATABASE_NAME);

						return BasePeer::doSelect($criteria, $con);
	}
	
	public static function populateObjects(ResultSet $rs)
	{
		$results = array();
	
				$cls = ConsultaPeer::getOMClass();
		$cls = Propel::import($cls);
				while($rs->next()) {
		
			$obj = new $cls();
			$obj->hydrate($rs);
			$results[] = $obj;
			
		}
		return $results;
	}

	
	public static function doCountJoinDiagnostico(Criteria $criteria, $distinct = false, $con = null)
	{
				$criteria = clone $criteria;

				$criteria->clearSelectColumns()->clearOrderByColumns();
		if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
			$criteria->addSelectColumn(ConsultaPeer::COUNT_DISTINCT);
		} else {
			$criteria->addSelectColumn(ConsultaPeer::COUNT);
		}

				foreach($criteria->getGroupByColumns() as $column)
		{
			$criteria->addSelectColumn($column);
		}

		$criteria->addJoin(ConsultaPeer::DIAGNOSTICO_ID, DiagnosticoPeer::ID);

		$rs = ConsultaPeer::doSelectRS($criteria, $con);
		if ($rs->next()) {
			return $rs->getInt(1);
		} else {
						return 0;
		}
	}


	
	public static function doCountJoinDatoEstudiante(Criteria $criteria, $distinct = false, $con = null)
	{
				$criteria = clone $criteria;

				$criteria->clearSelectColumns()->clearOrderByColumns();
		if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
			$criteria->addSelectColumn(ConsultaPeer::COUNT_DISTINCT);
		} else {
			$criteria->addSelectColumn(ConsultaPeer::COUNT);
		}

				foreach($criteria->getGroupByColumns() as $column)
		{
			$criteria->addSelectColumn($column);
		}

		$criteria->addJoin(ConsultaPeer::ESTUDIANTE_ID, DatoEstudiantePeer::ID);

		$rs = ConsultaPeer::doSelectRS($criteria, $con);
		if ($rs->next()) {
			return $rs->getInt(1);
		} else {
						return 0;
		}
	}


	
	public static function doCountJoinAteneausuario(Criteria $criteria, $distinct = false, $con = null)
	{
				$criteria = clone $criteria;

				$criteria->clearSelectColumns()->clearOrderByColumns();
		if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
			$criteria->addSelectColumn(ConsultaPeer::COUNT_DISTINCT);
		} else {
			$criteria->addSelectColumn(ConsultaPeer::COUNT);
		}

				foreach($criteria->getGroupByColumns() as $column)
		{
			$criteria->addSelectColumn($column);
		}

		$criteria->addJoin(ConsultaPeer::ENTREVISTADO_POR_ID, AteneausuarioPeer::ID);

		$rs = ConsultaPeer::doSelectRS($criteria, $con);
		if ($rs->next()) {
			return $rs->getInt(1);
		} else {
						return 0;
		}
	}


	
	public static function doCountJoinMotivoConsulta(Criteria $criteria, $distinct = false, $con = null)
	{
				$criteria = clone $criteria;

				$criteria->clearSelectColumns()->clearOrderByColumns();
		if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
			$criteria->addSelectColumn(ConsultaPeer::COUNT_DISTINCT);
		} else {
			$criteria->addSelectColumn(ConsultaPeer::COUNT);
		}

				foreach($criteria->getGroupByColumns() as $column)
		{
			$criteria->addSelectColumn($column);
		}

		$criteria->addJoin(ConsultaPeer::MOTIVO_CONSULTA_ID, MotivoConsultaPeer::ID);

		$rs = ConsultaPeer::doSelectRS($criteria, $con);
		if ($rs->next()) {
			return $rs->getInt(1);
		} else {
						return 0;
		}
	}


	
	public static function doCountJoinTrastorno(Criteria $criteria, $distinct = false, $con = null)
	{
				$criteria = clone $criteria;

				$criteria->clearSelectColumns()->clearOrderByColumns();
		if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
			$criteria->addSelectColumn(ConsultaPeer::COUNT_DISTINCT);
		} else {
			$criteria->addSelectColumn(ConsultaPeer::COUNT);
		}

				foreach($criteria->getGroupByColumns() as $column)
		{
			$criteria->addSelectColumn($column);
		}

		$criteria->addJoin(ConsultaPeer::TRASTORNO_ID, TrastornoPeer::ID);

		$rs = ConsultaPeer::doSelectRS($criteria, $con);
		if ($rs->next()) {
			return $rs->getInt(1);
		} else {
						return 0;
		}
	}


	
	public static function doCountJoinHistoriaPsicologica(Criteria $criteria, $distinct = false, $con = null)
	{
				$criteria = clone $criteria;

				$criteria->clearSelectColumns()->clearOrderByColumns();
		if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
			$criteria->addSelectColumn(ConsultaPeer::COUNT_DISTINCT);
		} else {
			$criteria->addSelectColumn(ConsultaPeer::COUNT);
		}

				foreach($criteria->getGroupByColumns() as $column)
		{
			$criteria->addSelectColumn($column);
		}

		$criteria->addJoin(ConsultaPeer::HIST_PSICOLOGICA_ID, HistoriaPsicologicaPeer::ID);

		$rs = ConsultaPeer::doSelectRS($criteria, $con);
		if ($rs->next()) {
			return $rs->getInt(1);
		} else {
						return 0;
		}
	}


	
	public static function doCountJoinCita(Criteria $criteria, $distinct = false, $con = null)
	{
				$criteria = clone $criteria;

				$criteria->clearSelectColumns()->clearOrderByColumns();
		if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
			$criteria->addSelectColumn(ConsultaPeer::COUNT_DISTINCT);
		} else {
			$criteria->addSelectColumn(ConsultaPeer::COUNT);
		}

				foreach($criteria->getGroupByColumns() as $column)
		{
			$criteria->addSelectColumn($column);
		}

		$criteria->addJoin(ConsultaPeer::CITA_ID, CitaPeer::ID);

		$rs = ConsultaPeer::doSelectRS($criteria, $con);
		if ($rs->next()) {
			return $rs->getInt(1);
		} else {
						return 0;
		}
	}


	
	public static function doSelectJoinDiagnostico(Criteria $c, $con = null)
	{
		$c = clone $c;

				if ($c->getDbName() == Propel::getDefaultDB()) {
			$c->setDbName(self::DATABASE_NAME);
		}

		ConsultaPeer::addSelectColumns($c);
		$startcol = (ConsultaPeer::NUM_COLUMNS - ConsultaPeer::NUM_LAZY_LOAD_COLUMNS) + 1;
		DiagnosticoPeer::addSelectColumns($c);

		$c->addJoin(ConsultaPeer::DIAGNOSTICO_ID, DiagnosticoPeer::ID);
		$rs = BasePeer::doSelect($c, $con);
		$results = array();

		while($rs->next()) {

			$omClass = ConsultaPeer::getOMClass();

			$cls = Propel::import($omClass);
			$obj1 = new $cls();
			$obj1->hydrate($rs);

			$omClass = DiagnosticoPeer::getOMClass();

			$cls = Propel::import($omClass);
			$obj2 = new $cls();
			$obj2->hydrate($rs, $startcol);

			$newObject = true;
			foreach($results as $temp_obj1) {
				$temp_obj2 = $temp_obj1->getDiagnostico(); 				if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
					$newObject = false;
										$temp_obj2->addConsulta($obj1); 					break;
				}
			}
			if ($newObject) {
				$obj2->initConsultas();
				$obj2->addConsulta($obj1); 			}
			$results[] = $obj1;
		}
		return $results;
	}


	
	public static function doSelectJoinDatoEstudiante(Criteria $c, $con = null)
	{
		$c = clone $c;

				if ($c->getDbName() == Propel::getDefaultDB()) {
			$c->setDbName(self::DATABASE_NAME);
		}

		ConsultaPeer::addSelectColumns($c);
		$startcol = (ConsultaPeer::NUM_COLUMNS - ConsultaPeer::NUM_LAZY_LOAD_COLUMNS) + 1;
		DatoEstudiantePeer::addSelectColumns($c);

		$c->addJoin(ConsultaPeer::ESTUDIANTE_ID, DatoEstudiantePeer::ID);
		$rs = BasePeer::doSelect($c, $con);
		$results = array();

		while($rs->next()) {

			$omClass = ConsultaPeer::getOMClass();

			$cls = Propel::import($omClass);
			$obj1 = new $cls();
			$obj1->hydrate($rs);

			$omClass = DatoEstudiantePeer::getOMClass();

			$cls = Propel::import($omClass);
			$obj2 = new $cls();
			$obj2->hydrate($rs, $startcol);

			$newObject = true;
			foreach($results as $temp_obj1) {
				$temp_obj2 = $temp_obj1->getDatoEstudiante(); 				if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
					$newObject = false;
										$temp_obj2->addConsulta($obj1); 					break;
				}
			}
			if ($newObject) {
				$obj2->initConsultas();
				$obj2->addConsulta($obj1); 			}
			$results[] = $obj1;
		}
		return $results;
	}


	
	public static function doSelectJoinAteneausuario(Criteria $c, $con = null)
	{
		$c = clone $c;

				if ($c->getDbName() == Propel::getDefaultDB()) {
			$c->setDbName(self::DATABASE_NAME);
		}

		ConsultaPeer::addSelectColumns($c);
		$startcol = (ConsultaPeer::NUM_COLUMNS - ConsultaPeer::NUM_LAZY_LOAD_COLUMNS) + 1;
		AteneausuarioPeer::addSelectColumns($c);

		$c->addJoin(ConsultaPeer::ENTREVISTADO_POR_ID, AteneausuarioPeer::ID);
		$rs = BasePeer::doSelect($c, $con);
		$results = array();

		while($rs->next()) {

			$omClass = ConsultaPeer::getOMClass();

			$cls = Propel::import($omClass);
			$obj1 = new $cls();
			$obj1->hydrate($rs);

			$omClass = AteneausuarioPeer::getOMClass();

			$cls = Propel::import($omClass);
			$obj2 = new $cls();
			$obj2->hydrate($rs, $startcol);

			$newObject = true;
			foreach($results as $temp_obj1) {
				$temp_obj2 = $temp_obj1->getAteneausuario(); 				if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
					$newObject = false;
										$temp_obj2->addConsulta($obj1); 					break;
				}
			}
			if ($newObject) {
				$obj2->initConsultas();
				$obj2->addConsulta($obj1); 			}
			$results[] = $obj1;
		}
		return $results;
	}


	
	public static function doSelectJoinMotivoConsulta(Criteria $c, $con = null)
	{
		$c = clone $c;

				if ($c->getDbName() == Propel::getDefaultDB()) {
			$c->setDbName(self::DATABASE_NAME);
		}

		ConsultaPeer::addSelectColumns($c);
		$startcol = (ConsultaPeer::NUM_COLUMNS - ConsultaPeer::NUM_LAZY_LOAD_COLUMNS) + 1;
		MotivoConsultaPeer::addSelectColumns($c);

		$c->addJoin(ConsultaPeer::MOTIVO_CONSULTA_ID, MotivoConsultaPeer::ID);
		$rs = BasePeer::doSelect($c, $con);
		$results = array();

		while($rs->next()) {

			$omClass = ConsultaPeer::getOMClass();

			$cls = Propel::import($omClass);
			$obj1 = new $cls();
			$obj1->hydrate($rs);

			$omClass = MotivoConsultaPeer::getOMClass();

			$cls = Propel::import($omClass);
			$obj2 = new $cls();
			$obj2->hydrate($rs, $startcol);

			$newObject = true;
			foreach($results as $temp_obj1) {
				$temp_obj2 = $temp_obj1->getMotivoConsulta(); 				if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
					$newObject = false;
										$temp_obj2->addConsulta($obj1); 					break;
				}
			}
			if ($newObject) {
				$obj2->initConsultas();
				$obj2->addConsulta($obj1); 			}
			$results[] = $obj1;
		}
		return $results;
	}


	
	public static function doSelectJoinTrastorno(Criteria $c, $con = null)
	{
		$c = clone $c;

				if ($c->getDbName() == Propel::getDefaultDB()) {
			$c->setDbName(self::DATABASE_NAME);
		}

		ConsultaPeer::addSelectColumns($c);
		$startcol = (ConsultaPeer::NUM_COLUMNS - ConsultaPeer::NUM_LAZY_LOAD_COLUMNS) + 1;
		TrastornoPeer::addSelectColumns($c);

		$c->addJoin(ConsultaPeer::TRASTORNO_ID, TrastornoPeer::ID);
		$rs = BasePeer::doSelect($c, $con);
		$results = array();

		while($rs->next()) {

			$omClass = ConsultaPeer::getOMClass();

			$cls = Propel::import($omClass);
			$obj1 = new $cls();
			$obj1->hydrate($rs);

			$omClass = TrastornoPeer::getOMClass();

			$cls = Propel::import($omClass);
			$obj2 = new $cls();
			$obj2->hydrate($rs, $startcol);

			$newObject = true;
			foreach($results as $temp_obj1) {
				$temp_obj2 = $temp_obj1->getTrastorno(); 				if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
					$newObject = false;
										$temp_obj2->addConsulta($obj1); 					break;
				}
			}
			if ($newObject) {
				$obj2->initConsultas();
				$obj2->addConsulta($obj1); 			}
			$results[] = $obj1;
		}
		return $results;
	}


	
	public static function doSelectJoinHistoriaPsicologica(Criteria $c, $con = null)
	{
		$c = clone $c;

				if ($c->getDbName() == Propel::getDefaultDB()) {
			$c->setDbName(self::DATABASE_NAME);
		}

		ConsultaPeer::addSelectColumns($c);
		$startcol = (ConsultaPeer::NUM_COLUMNS - ConsultaPeer::NUM_LAZY_LOAD_COLUMNS) + 1;
		HistoriaPsicologicaPeer::addSelectColumns($c);

		$c->addJoin(ConsultaPeer::HIST_PSICOLOGICA_ID, HistoriaPsicologicaPeer::ID);
		$rs = BasePeer::doSelect($c, $con);
		$results = array();

		while($rs->next()) {

			$omClass = ConsultaPeer::getOMClass();

			$cls = Propel::import($omClass);
			$obj1 = new $cls();
			$obj1->hydrate($rs);

			$omClass = HistoriaPsicologicaPeer::getOMClass();

			$cls = Propel::import($omClass);
			$obj2 = new $cls();
			$obj2->hydrate($rs, $startcol);

			$newObject = true;
			foreach($results as $temp_obj1) {
				$temp_obj2 = $temp_obj1->getHistoriaPsicologica(); 				if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
					$newObject = false;
										$temp_obj2->addConsulta($obj1); 					break;
				}
			}
			if ($newObject) {
				$obj2->initConsultas();
				$obj2->addConsulta($obj1); 			}
			$results[] = $obj1;
		}
		return $results;
	}


	
	public static function doSelectJoinCita(Criteria $c, $con = null)
	{
		$c = clone $c;

				if ($c->getDbName() == Propel::getDefaultDB()) {
			$c->setDbName(self::DATABASE_NAME);
		}

		ConsultaPeer::addSelectColumns($c);
		$startcol = (ConsultaPeer::NUM_COLUMNS - ConsultaPeer::NUM_LAZY_LOAD_COLUMNS) + 1;
		CitaPeer::addSelectColumns($c);

		$c->addJoin(ConsultaPeer::CITA_ID, CitaPeer::ID);
		$rs = BasePeer::doSelect($c, $con);
		$results = array();

		while($rs->next()) {

			$omClass = ConsultaPeer::getOMClass();

			$cls = Propel::import($omClass);
			$obj1 = new $cls();
			$obj1->hydrate($rs);

			$omClass = CitaPeer::getOMClass();

			$cls = Propel::import($omClass);
			$obj2 = new $cls();
			$obj2->hydrate($rs, $startcol);

			$newObject = true;
			foreach($results as $temp_obj1) {
				$temp_obj2 = $temp_obj1->getCita(); 				if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
					$newObject = false;
										$temp_obj2->addConsulta($obj1); 					break;
				}
			}
			if ($newObject) {
				$obj2->initConsultas();
				$obj2->addConsulta($obj1); 			}
			$results[] = $obj1;
		}
		return $results;
	}


	
	public static function doCountJoinAll(Criteria $criteria, $distinct = false, $con = null)
	{
		$criteria = clone $criteria;

				$criteria->clearSelectColumns()->clearOrderByColumns();
		if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
			$criteria->addSelectColumn(ConsultaPeer::COUNT_DISTINCT);
		} else {
			$criteria->addSelectColumn(ConsultaPeer::COUNT);
		}

				foreach($criteria->getGroupByColumns() as $column)
		{
			$criteria->addSelectColumn($column);
		}

		$criteria->addJoin(ConsultaPeer::DIAGNOSTICO_ID, DiagnosticoPeer::ID);

		$criteria->addJoin(ConsultaPeer::ESTUDIANTE_ID, DatoEstudiantePeer::ID);

		$criteria->addJoin(ConsultaPeer::ENTREVISTADO_POR_ID, AteneausuarioPeer::ID);

		$criteria->addJoin(ConsultaPeer::MOTIVO_CONSULTA_ID, MotivoConsultaPeer::ID);

		$criteria->addJoin(ConsultaPeer::TRASTORNO_ID, TrastornoPeer::ID);

		$criteria->addJoin(ConsultaPeer::HIST_PSICOLOGICA_ID, HistoriaPsicologicaPeer::ID);

		$criteria->addJoin(ConsultaPeer::CITA_ID, CitaPeer::ID);

		$rs = ConsultaPeer::doSelectRS($criteria, $con);
		if ($rs->next()) {
			return $rs->getInt(1);
		} else {
						return 0;
		}
	}


	
	public static function doSelectJoinAll(Criteria $c, $con = null)
	{
		$c = clone $c;

				if ($c->getDbName() == Propel::getDefaultDB()) {
			$c->setDbName(self::DATABASE_NAME);
		}

		ConsultaPeer::addSelectColumns($c);
		$startcol2 = (ConsultaPeer::NUM_COLUMNS - ConsultaPeer::NUM_LAZY_LOAD_COLUMNS) + 1;

		DiagnosticoPeer::addSelectColumns($c);
		$startcol3 = $startcol2 + DiagnosticoPeer::NUM_COLUMNS;

		DatoEstudiantePeer::addSelectColumns($c);
		$startcol4 = $startcol3 + DatoEstudiantePeer::NUM_COLUMNS;

		AteneausuarioPeer::addSelectColumns($c);
		$startcol5 = $startcol4 + AteneausuarioPeer::NUM_COLUMNS;

		MotivoConsultaPeer::addSelectColumns($c);
		$startcol6 = $startcol5 + MotivoConsultaPeer::NUM_COLUMNS;

		TrastornoPeer::addSelectColumns($c);
		$startcol7 = $startcol6 + TrastornoPeer::NUM_COLUMNS;

		HistoriaPsicologicaPeer::addSelectColumns($c);
		$startcol8 = $startcol7 + HistoriaPsicologicaPeer::NUM_COLUMNS;

		CitaPeer::addSelectColumns($c);
		$startcol9 = $startcol8 + CitaPeer::NUM_COLUMNS;

		$c->addJoin(ConsultaPeer::DIAGNOSTICO_ID, DiagnosticoPeer::ID);

		$c->addJoin(ConsultaPeer::ESTUDIANTE_ID, DatoEstudiantePeer::ID);

		$c->addJoin(ConsultaPeer::ENTREVISTADO_POR_ID, AteneausuarioPeer::ID);

		$c->addJoin(ConsultaPeer::MOTIVO_CONSULTA_ID, MotivoConsultaPeer::ID);

		$c->addJoin(ConsultaPeer::TRASTORNO_ID, TrastornoPeer::ID);

		$c->addJoin(ConsultaPeer::HIST_PSICOLOGICA_ID, HistoriaPsicologicaPeer::ID);

		$c->addJoin(ConsultaPeer::CITA_ID, CitaPeer::ID);

		$rs = BasePeer::doSelect($c, $con);
		$results = array();

		while($rs->next()) {

			$omClass = ConsultaPeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj1 = new $cls();
			$obj1->hydrate($rs);


					
			$omClass = DiagnosticoPeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj2 = new $cls();
			$obj2->hydrate($rs, $startcol2);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj2 = $temp_obj1->getDiagnostico(); 				if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
					$newObject = false;
					$temp_obj2->addConsulta($obj1); 					break;
				}
			}

			if ($newObject) {
				$obj2->initConsultas();
				$obj2->addConsulta($obj1);
			}


					
			$omClass = DatoEstudiantePeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj3 = new $cls();
			$obj3->hydrate($rs, $startcol3);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj3 = $temp_obj1->getDatoEstudiante(); 				if ($temp_obj3->getPrimaryKey() === $obj3->getPrimaryKey()) {
					$newObject = false;
					$temp_obj3->addConsulta($obj1); 					break;
				}
			}

			if ($newObject) {
				$obj3->initConsultas();
				$obj3->addConsulta($obj1);
			}


					
			$omClass = AteneausuarioPeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj4 = new $cls();
			$obj4->hydrate($rs, $startcol4);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj4 = $temp_obj1->getAteneausuario(); 				if ($temp_obj4->getPrimaryKey() === $obj4->getPrimaryKey()) {
					$newObject = false;
					$temp_obj4->addConsulta($obj1); 					break;
				}
			}

			if ($newObject) {
				$obj4->initConsultas();
				$obj4->addConsulta($obj1);
			}


					
			$omClass = MotivoConsultaPeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj5 = new $cls();
			$obj5->hydrate($rs, $startcol5);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj5 = $temp_obj1->getMotivoConsulta(); 				if ($temp_obj5->getPrimaryKey() === $obj5->getPrimaryKey()) {
					$newObject = false;
					$temp_obj5->addConsulta($obj1); 					break;
				}
			}

			if ($newObject) {
				$obj5->initConsultas();
				$obj5->addConsulta($obj1);
			}


					
			$omClass = TrastornoPeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj6 = new $cls();
			$obj6->hydrate($rs, $startcol6);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj6 = $temp_obj1->getTrastorno(); 				if ($temp_obj6->getPrimaryKey() === $obj6->getPrimaryKey()) {
					$newObject = false;
					$temp_obj6->addConsulta($obj1); 					break;
				}
			}

			if ($newObject) {
				$obj6->initConsultas();
				$obj6->addConsulta($obj1);
			}


					
			$omClass = HistoriaPsicologicaPeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj7 = new $cls();
			$obj7->hydrate($rs, $startcol7);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj7 = $temp_obj1->getHistoriaPsicologica(); 				if ($temp_obj7->getPrimaryKey() === $obj7->getPrimaryKey()) {
					$newObject = false;
					$temp_obj7->addConsulta($obj1); 					break;
				}
			}

			if ($newObject) {
				$obj7->initConsultas();
				$obj7->addConsulta($obj1);
			}


					
			$omClass = CitaPeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj8 = new $cls();
			$obj8->hydrate($rs, $startcol8);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj8 = $temp_obj1->getCita(); 				if ($temp_obj8->getPrimaryKey() === $obj8->getPrimaryKey()) {
					$newObject = false;
					$temp_obj8->addConsulta($obj1); 					break;
				}
			}

			if ($newObject) {
				$obj8->initConsultas();
				$obj8->addConsulta($obj1);
			}

			$results[] = $obj1;
		}
		return $results;
	}


	
	public static function doCountJoinAllExceptDiagnostico(Criteria $criteria, $distinct = false, $con = null)
	{
				$criteria = clone $criteria;

				$criteria->clearSelectColumns()->clearOrderByColumns();
		if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
			$criteria->addSelectColumn(ConsultaPeer::COUNT_DISTINCT);
		} else {
			$criteria->addSelectColumn(ConsultaPeer::COUNT);
		}

				foreach($criteria->getGroupByColumns() as $column)
		{
			$criteria->addSelectColumn($column);
		}

		$criteria->addJoin(ConsultaPeer::ESTUDIANTE_ID, DatoEstudiantePeer::ID);

		$criteria->addJoin(ConsultaPeer::ENTREVISTADO_POR_ID, AteneausuarioPeer::ID);

		$criteria->addJoin(ConsultaPeer::MOTIVO_CONSULTA_ID, MotivoConsultaPeer::ID);

		$criteria->addJoin(ConsultaPeer::TRASTORNO_ID, TrastornoPeer::ID);

		$criteria->addJoin(ConsultaPeer::HIST_PSICOLOGICA_ID, HistoriaPsicologicaPeer::ID);

		$criteria->addJoin(ConsultaPeer::CITA_ID, CitaPeer::ID);

		$rs = ConsultaPeer::doSelectRS($criteria, $con);
		if ($rs->next()) {
			return $rs->getInt(1);
		} else {
						return 0;
		}
	}


	
	public static function doCountJoinAllExceptDatoEstudiante(Criteria $criteria, $distinct = false, $con = null)
	{
				$criteria = clone $criteria;

				$criteria->clearSelectColumns()->clearOrderByColumns();
		if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
			$criteria->addSelectColumn(ConsultaPeer::COUNT_DISTINCT);
		} else {
			$criteria->addSelectColumn(ConsultaPeer::COUNT);
		}

				foreach($criteria->getGroupByColumns() as $column)
		{
			$criteria->addSelectColumn($column);
		}

		$criteria->addJoin(ConsultaPeer::DIAGNOSTICO_ID, DiagnosticoPeer::ID);

		$criteria->addJoin(ConsultaPeer::ENTREVISTADO_POR_ID, AteneausuarioPeer::ID);

		$criteria->addJoin(ConsultaPeer::MOTIVO_CONSULTA_ID, MotivoConsultaPeer::ID);

		$criteria->addJoin(ConsultaPeer::TRASTORNO_ID, TrastornoPeer::ID);

		$criteria->addJoin(ConsultaPeer::HIST_PSICOLOGICA_ID, HistoriaPsicologicaPeer::ID);

		$criteria->addJoin(ConsultaPeer::CITA_ID, CitaPeer::ID);

		$rs = ConsultaPeer::doSelectRS($criteria, $con);
		if ($rs->next()) {
			return $rs->getInt(1);
		} else {
						return 0;
		}
	}


	
	public static function doCountJoinAllExceptAteneausuario(Criteria $criteria, $distinct = false, $con = null)
	{
				$criteria = clone $criteria;

				$criteria->clearSelectColumns()->clearOrderByColumns();
		if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
			$criteria->addSelectColumn(ConsultaPeer::COUNT_DISTINCT);
		} else {
			$criteria->addSelectColumn(ConsultaPeer::COUNT);
		}

				foreach($criteria->getGroupByColumns() as $column)
		{
			$criteria->addSelectColumn($column);
		}

		$criteria->addJoin(ConsultaPeer::DIAGNOSTICO_ID, DiagnosticoPeer::ID);

		$criteria->addJoin(ConsultaPeer::ESTUDIANTE_ID, DatoEstudiantePeer::ID);

		$criteria->addJoin(ConsultaPeer::MOTIVO_CONSULTA_ID, MotivoConsultaPeer::ID);

		$criteria->addJoin(ConsultaPeer::TRASTORNO_ID, TrastornoPeer::ID);

		$criteria->addJoin(ConsultaPeer::HIST_PSICOLOGICA_ID, HistoriaPsicologicaPeer::ID);

		$criteria->addJoin(ConsultaPeer::CITA_ID, CitaPeer::ID);

		$rs = ConsultaPeer::doSelectRS($criteria, $con);
		if ($rs->next()) {
			return $rs->getInt(1);
		} else {
						return 0;
		}
	}


	
	public static function doCountJoinAllExceptMotivoConsulta(Criteria $criteria, $distinct = false, $con = null)
	{
				$criteria = clone $criteria;

				$criteria->clearSelectColumns()->clearOrderByColumns();
		if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
			$criteria->addSelectColumn(ConsultaPeer::COUNT_DISTINCT);
		} else {
			$criteria->addSelectColumn(ConsultaPeer::COUNT);
		}

				foreach($criteria->getGroupByColumns() as $column)
		{
			$criteria->addSelectColumn($column);
		}

		$criteria->addJoin(ConsultaPeer::DIAGNOSTICO_ID, DiagnosticoPeer::ID);

		$criteria->addJoin(ConsultaPeer::ESTUDIANTE_ID, DatoEstudiantePeer::ID);

		$criteria->addJoin(ConsultaPeer::ENTREVISTADO_POR_ID, AteneausuarioPeer::ID);

		$criteria->addJoin(ConsultaPeer::TRASTORNO_ID, TrastornoPeer::ID);

		$criteria->addJoin(ConsultaPeer::HIST_PSICOLOGICA_ID, HistoriaPsicologicaPeer::ID);

		$criteria->addJoin(ConsultaPeer::CITA_ID, CitaPeer::ID);

		$rs = ConsultaPeer::doSelectRS($criteria, $con);
		if ($rs->next()) {
			return $rs->getInt(1);
		} else {
						return 0;
		}
	}


	
	public static function doCountJoinAllExceptTrastorno(Criteria $criteria, $distinct = false, $con = null)
	{
				$criteria = clone $criteria;

				$criteria->clearSelectColumns()->clearOrderByColumns();
		if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
			$criteria->addSelectColumn(ConsultaPeer::COUNT_DISTINCT);
		} else {
			$criteria->addSelectColumn(ConsultaPeer::COUNT);
		}

				foreach($criteria->getGroupByColumns() as $column)
		{
			$criteria->addSelectColumn($column);
		}

		$criteria->addJoin(ConsultaPeer::DIAGNOSTICO_ID, DiagnosticoPeer::ID);

		$criteria->addJoin(ConsultaPeer::ESTUDIANTE_ID, DatoEstudiantePeer::ID);

		$criteria->addJoin(ConsultaPeer::ENTREVISTADO_POR_ID, AteneausuarioPeer::ID);

		$criteria->addJoin(ConsultaPeer::MOTIVO_CONSULTA_ID, MotivoConsultaPeer::ID);

		$criteria->addJoin(ConsultaPeer::HIST_PSICOLOGICA_ID, HistoriaPsicologicaPeer::ID);

		$criteria->addJoin(ConsultaPeer::CITA_ID, CitaPeer::ID);

		$rs = ConsultaPeer::doSelectRS($criteria, $con);
		if ($rs->next()) {
			return $rs->getInt(1);
		} else {
						return 0;
		}
	}


	
	public static function doCountJoinAllExceptHistoriaPsicologica(Criteria $criteria, $distinct = false, $con = null)
	{
				$criteria = clone $criteria;

				$criteria->clearSelectColumns()->clearOrderByColumns();
		if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
			$criteria->addSelectColumn(ConsultaPeer::COUNT_DISTINCT);
		} else {
			$criteria->addSelectColumn(ConsultaPeer::COUNT);
		}

				foreach($criteria->getGroupByColumns() as $column)
		{
			$criteria->addSelectColumn($column);
		}

		$criteria->addJoin(ConsultaPeer::DIAGNOSTICO_ID, DiagnosticoPeer::ID);

		$criteria->addJoin(ConsultaPeer::ESTUDIANTE_ID, DatoEstudiantePeer::ID);

		$criteria->addJoin(ConsultaPeer::ENTREVISTADO_POR_ID, AteneausuarioPeer::ID);

		$criteria->addJoin(ConsultaPeer::MOTIVO_CONSULTA_ID, MotivoConsultaPeer::ID);

		$criteria->addJoin(ConsultaPeer::TRASTORNO_ID, TrastornoPeer::ID);

		$criteria->addJoin(ConsultaPeer::CITA_ID, CitaPeer::ID);

		$rs = ConsultaPeer::doSelectRS($criteria, $con);
		if ($rs->next()) {
			return $rs->getInt(1);
		} else {
						return 0;
		}
	}


	
	public static function doCountJoinAllExceptCita(Criteria $criteria, $distinct = false, $con = null)
	{
				$criteria = clone $criteria;

				$criteria->clearSelectColumns()->clearOrderByColumns();
		if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
			$criteria->addSelectColumn(ConsultaPeer::COUNT_DISTINCT);
		} else {
			$criteria->addSelectColumn(ConsultaPeer::COUNT);
		}

				foreach($criteria->getGroupByColumns() as $column)
		{
			$criteria->addSelectColumn($column);
		}

		$criteria->addJoin(ConsultaPeer::DIAGNOSTICO_ID, DiagnosticoPeer::ID);

		$criteria->addJoin(ConsultaPeer::ESTUDIANTE_ID, DatoEstudiantePeer::ID);

		$criteria->addJoin(ConsultaPeer::ENTREVISTADO_POR_ID, AteneausuarioPeer::ID);

		$criteria->addJoin(ConsultaPeer::MOTIVO_CONSULTA_ID, MotivoConsultaPeer::ID);

		$criteria->addJoin(ConsultaPeer::TRASTORNO_ID, TrastornoPeer::ID);

		$criteria->addJoin(ConsultaPeer::HIST_PSICOLOGICA_ID, HistoriaPsicologicaPeer::ID);

		$rs = ConsultaPeer::doSelectRS($criteria, $con);
		if ($rs->next()) {
			return $rs->getInt(1);
		} else {
						return 0;
		}
	}


	
	public static function doSelectJoinAllExceptDiagnostico(Criteria $c, $con = null)
	{
		$c = clone $c;

								if ($c->getDbName() == Propel::getDefaultDB()) {
			$c->setDbName(self::DATABASE_NAME);
		}

		ConsultaPeer::addSelectColumns($c);
		$startcol2 = (ConsultaPeer::NUM_COLUMNS - ConsultaPeer::NUM_LAZY_LOAD_COLUMNS) + 1;

		DatoEstudiantePeer::addSelectColumns($c);
		$startcol3 = $startcol2 + DatoEstudiantePeer::NUM_COLUMNS;

		AteneausuarioPeer::addSelectColumns($c);
		$startcol4 = $startcol3 + AteneausuarioPeer::NUM_COLUMNS;

		MotivoConsultaPeer::addSelectColumns($c);
		$startcol5 = $startcol4 + MotivoConsultaPeer::NUM_COLUMNS;

		TrastornoPeer::addSelectColumns($c);
		$startcol6 = $startcol5 + TrastornoPeer::NUM_COLUMNS;

		HistoriaPsicologicaPeer::addSelectColumns($c);
		$startcol7 = $startcol6 + HistoriaPsicologicaPeer::NUM_COLUMNS;

		CitaPeer::addSelectColumns($c);
		$startcol8 = $startcol7 + CitaPeer::NUM_COLUMNS;

		$c->addJoin(ConsultaPeer::ESTUDIANTE_ID, DatoEstudiantePeer::ID);

		$c->addJoin(ConsultaPeer::ENTREVISTADO_POR_ID, AteneausuarioPeer::ID);

		$c->addJoin(ConsultaPeer::MOTIVO_CONSULTA_ID, MotivoConsultaPeer::ID);

		$c->addJoin(ConsultaPeer::TRASTORNO_ID, TrastornoPeer::ID);

		$c->addJoin(ConsultaPeer::HIST_PSICOLOGICA_ID, HistoriaPsicologicaPeer::ID);

		$c->addJoin(ConsultaPeer::CITA_ID, CitaPeer::ID);


		$rs = BasePeer::doSelect($c, $con);
		$results = array();

		while($rs->next()) {

			$omClass = ConsultaPeer::getOMClass();

			$cls = Propel::import($omClass);
			$obj1 = new $cls();
			$obj1->hydrate($rs);

			$omClass = DatoEstudiantePeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj2  = new $cls();
			$obj2->hydrate($rs, $startcol2);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj2 = $temp_obj1->getDatoEstudiante(); 				if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
					$newObject = false;
					$temp_obj2->addConsulta($obj1);
					break;
				}
			}

			if ($newObject) {
				$obj2->initConsultas();
				$obj2->addConsulta($obj1);
			}

			$omClass = AteneausuarioPeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj3  = new $cls();
			$obj3->hydrate($rs, $startcol3);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj3 = $temp_obj1->getAteneausuario(); 				if ($temp_obj3->getPrimaryKey() === $obj3->getPrimaryKey()) {
					$newObject = false;
					$temp_obj3->addConsulta($obj1);
					break;
				}
			}

			if ($newObject) {
				$obj3->initConsultas();
				$obj3->addConsulta($obj1);
			}

			$omClass = MotivoConsultaPeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj4  = new $cls();
			$obj4->hydrate($rs, $startcol4);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj4 = $temp_obj1->getMotivoConsulta(); 				if ($temp_obj4->getPrimaryKey() === $obj4->getPrimaryKey()) {
					$newObject = false;
					$temp_obj4->addConsulta($obj1);
					break;
				}
			}

			if ($newObject) {
				$obj4->initConsultas();
				$obj4->addConsulta($obj1);
			}

			$omClass = TrastornoPeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj5  = new $cls();
			$obj5->hydrate($rs, $startcol5);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj5 = $temp_obj1->getTrastorno(); 				if ($temp_obj5->getPrimaryKey() === $obj5->getPrimaryKey()) {
					$newObject = false;
					$temp_obj5->addConsulta($obj1);
					break;
				}
			}

			if ($newObject) {
				$obj5->initConsultas();
				$obj5->addConsulta($obj1);
			}

			$omClass = HistoriaPsicologicaPeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj6  = new $cls();
			$obj6->hydrate($rs, $startcol6);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj6 = $temp_obj1->getHistoriaPsicologica(); 				if ($temp_obj6->getPrimaryKey() === $obj6->getPrimaryKey()) {
					$newObject = false;
					$temp_obj6->addConsulta($obj1);
					break;
				}
			}

			if ($newObject) {
				$obj6->initConsultas();
				$obj6->addConsulta($obj1);
			}

			$omClass = CitaPeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj7  = new $cls();
			$obj7->hydrate($rs, $startcol7);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj7 = $temp_obj1->getCita(); 				if ($temp_obj7->getPrimaryKey() === $obj7->getPrimaryKey()) {
					$newObject = false;
					$temp_obj7->addConsulta($obj1);
					break;
				}
			}

			if ($newObject) {
				$obj7->initConsultas();
				$obj7->addConsulta($obj1);
			}

			$results[] = $obj1;
		}
		return $results;
	}


	
	public static function doSelectJoinAllExceptDatoEstudiante(Criteria $c, $con = null)
	{
		$c = clone $c;

								if ($c->getDbName() == Propel::getDefaultDB()) {
			$c->setDbName(self::DATABASE_NAME);
		}

		ConsultaPeer::addSelectColumns($c);
		$startcol2 = (ConsultaPeer::NUM_COLUMNS - ConsultaPeer::NUM_LAZY_LOAD_COLUMNS) + 1;

		DiagnosticoPeer::addSelectColumns($c);
		$startcol3 = $startcol2 + DiagnosticoPeer::NUM_COLUMNS;

		AteneausuarioPeer::addSelectColumns($c);
		$startcol4 = $startcol3 + AteneausuarioPeer::NUM_COLUMNS;

		MotivoConsultaPeer::addSelectColumns($c);
		$startcol5 = $startcol4 + MotivoConsultaPeer::NUM_COLUMNS;

		TrastornoPeer::addSelectColumns($c);
		$startcol6 = $startcol5 + TrastornoPeer::NUM_COLUMNS;

		HistoriaPsicologicaPeer::addSelectColumns($c);
		$startcol7 = $startcol6 + HistoriaPsicologicaPeer::NUM_COLUMNS;

		CitaPeer::addSelectColumns($c);
		$startcol8 = $startcol7 + CitaPeer::NUM_COLUMNS;

		$c->addJoin(ConsultaPeer::DIAGNOSTICO_ID, DiagnosticoPeer::ID);

		$c->addJoin(ConsultaPeer::ENTREVISTADO_POR_ID, AteneausuarioPeer::ID);

		$c->addJoin(ConsultaPeer::MOTIVO_CONSULTA_ID, MotivoConsultaPeer::ID);

		$c->addJoin(ConsultaPeer::TRASTORNO_ID, TrastornoPeer::ID);

		$c->addJoin(ConsultaPeer::HIST_PSICOLOGICA_ID, HistoriaPsicologicaPeer::ID);

		$c->addJoin(ConsultaPeer::CITA_ID, CitaPeer::ID);


		$rs = BasePeer::doSelect($c, $con);
		$results = array();

		while($rs->next()) {

			$omClass = ConsultaPeer::getOMClass();

			$cls = Propel::import($omClass);
			$obj1 = new $cls();
			$obj1->hydrate($rs);

			$omClass = DiagnosticoPeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj2  = new $cls();
			$obj2->hydrate($rs, $startcol2);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj2 = $temp_obj1->getDiagnostico(); 				if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
					$newObject = false;
					$temp_obj2->addConsulta($obj1);
					break;
				}
			}

			if ($newObject) {
				$obj2->initConsultas();
				$obj2->addConsulta($obj1);
			}

			$omClass = AteneausuarioPeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj3  = new $cls();
			$obj3->hydrate($rs, $startcol3);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj3 = $temp_obj1->getAteneausuario(); 				if ($temp_obj3->getPrimaryKey() === $obj3->getPrimaryKey()) {
					$newObject = false;
					$temp_obj3->addConsulta($obj1);
					break;
				}
			}

			if ($newObject) {
				$obj3->initConsultas();
				$obj3->addConsulta($obj1);
			}

			$omClass = MotivoConsultaPeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj4  = new $cls();
			$obj4->hydrate($rs, $startcol4);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj4 = $temp_obj1->getMotivoConsulta(); 				if ($temp_obj4->getPrimaryKey() === $obj4->getPrimaryKey()) {
					$newObject = false;
					$temp_obj4->addConsulta($obj1);
					break;
				}
			}

			if ($newObject) {
				$obj4->initConsultas();
				$obj4->addConsulta($obj1);
			}

			$omClass = TrastornoPeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj5  = new $cls();
			$obj5->hydrate($rs, $startcol5);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj5 = $temp_obj1->getTrastorno(); 				if ($temp_obj5->getPrimaryKey() === $obj5->getPrimaryKey()) {
					$newObject = false;
					$temp_obj5->addConsulta($obj1);
					break;
				}
			}

			if ($newObject) {
				$obj5->initConsultas();
				$obj5->addConsulta($obj1);
			}

			$omClass = HistoriaPsicologicaPeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj6  = new $cls();
			$obj6->hydrate($rs, $startcol6);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj6 = $temp_obj1->getHistoriaPsicologica(); 				if ($temp_obj6->getPrimaryKey() === $obj6->getPrimaryKey()) {
					$newObject = false;
					$temp_obj6->addConsulta($obj1);
					break;
				}
			}

			if ($newObject) {
				$obj6->initConsultas();
				$obj6->addConsulta($obj1);
			}

			$omClass = CitaPeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj7  = new $cls();
			$obj7->hydrate($rs, $startcol7);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj7 = $temp_obj1->getCita(); 				if ($temp_obj7->getPrimaryKey() === $obj7->getPrimaryKey()) {
					$newObject = false;
					$temp_obj7->addConsulta($obj1);
					break;
				}
			}

			if ($newObject) {
				$obj7->initConsultas();
				$obj7->addConsulta($obj1);
			}

			$results[] = $obj1;
		}
		return $results;
	}


	
	public static function doSelectJoinAllExceptAteneausuario(Criteria $c, $con = null)
	{
		$c = clone $c;

								if ($c->getDbName() == Propel::getDefaultDB()) {
			$c->setDbName(self::DATABASE_NAME);
		}

		ConsultaPeer::addSelectColumns($c);
		$startcol2 = (ConsultaPeer::NUM_COLUMNS - ConsultaPeer::NUM_LAZY_LOAD_COLUMNS) + 1;

		DiagnosticoPeer::addSelectColumns($c);
		$startcol3 = $startcol2 + DiagnosticoPeer::NUM_COLUMNS;

		DatoEstudiantePeer::addSelectColumns($c);
		$startcol4 = $startcol3 + DatoEstudiantePeer::NUM_COLUMNS;

		MotivoConsultaPeer::addSelectColumns($c);
		$startcol5 = $startcol4 + MotivoConsultaPeer::NUM_COLUMNS;

		TrastornoPeer::addSelectColumns($c);
		$startcol6 = $startcol5 + TrastornoPeer::NUM_COLUMNS;

		HistoriaPsicologicaPeer::addSelectColumns($c);
		$startcol7 = $startcol6 + HistoriaPsicologicaPeer::NUM_COLUMNS;

		CitaPeer::addSelectColumns($c);
		$startcol8 = $startcol7 + CitaPeer::NUM_COLUMNS;

		$c->addJoin(ConsultaPeer::DIAGNOSTICO_ID, DiagnosticoPeer::ID);

		$c->addJoin(ConsultaPeer::ESTUDIANTE_ID, DatoEstudiantePeer::ID);

		$c->addJoin(ConsultaPeer::MOTIVO_CONSULTA_ID, MotivoConsultaPeer::ID);

		$c->addJoin(ConsultaPeer::TRASTORNO_ID, TrastornoPeer::ID);

		$c->addJoin(ConsultaPeer::HIST_PSICOLOGICA_ID, HistoriaPsicologicaPeer::ID);

		$c->addJoin(ConsultaPeer::CITA_ID, CitaPeer::ID);


		$rs = BasePeer::doSelect($c, $con);
		$results = array();

		while($rs->next()) {

			$omClass = ConsultaPeer::getOMClass();

			$cls = Propel::import($omClass);
			$obj1 = new $cls();
			$obj1->hydrate($rs);

			$omClass = DiagnosticoPeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj2  = new $cls();
			$obj2->hydrate($rs, $startcol2);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj2 = $temp_obj1->getDiagnostico(); 				if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
					$newObject = false;
					$temp_obj2->addConsulta($obj1);
					break;
				}
			}

			if ($newObject) {
				$obj2->initConsultas();
				$obj2->addConsulta($obj1);
			}

			$omClass = DatoEstudiantePeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj3  = new $cls();
			$obj3->hydrate($rs, $startcol3);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj3 = $temp_obj1->getDatoEstudiante(); 				if ($temp_obj3->getPrimaryKey() === $obj3->getPrimaryKey()) {
					$newObject = false;
					$temp_obj3->addConsulta($obj1);
					break;
				}
			}

			if ($newObject) {
				$obj3->initConsultas();
				$obj3->addConsulta($obj1);
			}

			$omClass = MotivoConsultaPeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj4  = new $cls();
			$obj4->hydrate($rs, $startcol4);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj4 = $temp_obj1->getMotivoConsulta(); 				if ($temp_obj4->getPrimaryKey() === $obj4->getPrimaryKey()) {
					$newObject = false;
					$temp_obj4->addConsulta($obj1);
					break;
				}
			}

			if ($newObject) {
				$obj4->initConsultas();
				$obj4->addConsulta($obj1);
			}

			$omClass = TrastornoPeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj5  = new $cls();
			$obj5->hydrate($rs, $startcol5);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj5 = $temp_obj1->getTrastorno(); 				if ($temp_obj5->getPrimaryKey() === $obj5->getPrimaryKey()) {
					$newObject = false;
					$temp_obj5->addConsulta($obj1);
					break;
				}
			}

			if ($newObject) {
				$obj5->initConsultas();
				$obj5->addConsulta($obj1);
			}

			$omClass = HistoriaPsicologicaPeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj6  = new $cls();
			$obj6->hydrate($rs, $startcol6);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj6 = $temp_obj1->getHistoriaPsicologica(); 				if ($temp_obj6->getPrimaryKey() === $obj6->getPrimaryKey()) {
					$newObject = false;
					$temp_obj6->addConsulta($obj1);
					break;
				}
			}

			if ($newObject) {
				$obj6->initConsultas();
				$obj6->addConsulta($obj1);
			}

			$omClass = CitaPeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj7  = new $cls();
			$obj7->hydrate($rs, $startcol7);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj7 = $temp_obj1->getCita(); 				if ($temp_obj7->getPrimaryKey() === $obj7->getPrimaryKey()) {
					$newObject = false;
					$temp_obj7->addConsulta($obj1);
					break;
				}
			}

			if ($newObject) {
				$obj7->initConsultas();
				$obj7->addConsulta($obj1);
			}

			$results[] = $obj1;
		}
		return $results;
	}


	
	public static function doSelectJoinAllExceptMotivoConsulta(Criteria $c, $con = null)
	{
		$c = clone $c;

								if ($c->getDbName() == Propel::getDefaultDB()) {
			$c->setDbName(self::DATABASE_NAME);
		}

		ConsultaPeer::addSelectColumns($c);
		$startcol2 = (ConsultaPeer::NUM_COLUMNS - ConsultaPeer::NUM_LAZY_LOAD_COLUMNS) + 1;

		DiagnosticoPeer::addSelectColumns($c);
		$startcol3 = $startcol2 + DiagnosticoPeer::NUM_COLUMNS;

		DatoEstudiantePeer::addSelectColumns($c);
		$startcol4 = $startcol3 + DatoEstudiantePeer::NUM_COLUMNS;

		AteneausuarioPeer::addSelectColumns($c);
		$startcol5 = $startcol4 + AteneausuarioPeer::NUM_COLUMNS;

		TrastornoPeer::addSelectColumns($c);
		$startcol6 = $startcol5 + TrastornoPeer::NUM_COLUMNS;

		HistoriaPsicologicaPeer::addSelectColumns($c);
		$startcol7 = $startcol6 + HistoriaPsicologicaPeer::NUM_COLUMNS;

		CitaPeer::addSelectColumns($c);
		$startcol8 = $startcol7 + CitaPeer::NUM_COLUMNS;

		$c->addJoin(ConsultaPeer::DIAGNOSTICO_ID, DiagnosticoPeer::ID);

		$c->addJoin(ConsultaPeer::ESTUDIANTE_ID, DatoEstudiantePeer::ID);

		$c->addJoin(ConsultaPeer::ENTREVISTADO_POR_ID, AteneausuarioPeer::ID);

		$c->addJoin(ConsultaPeer::TRASTORNO_ID, TrastornoPeer::ID);

		$c->addJoin(ConsultaPeer::HIST_PSICOLOGICA_ID, HistoriaPsicologicaPeer::ID);

		$c->addJoin(ConsultaPeer::CITA_ID, CitaPeer::ID);


		$rs = BasePeer::doSelect($c, $con);
		$results = array();

		while($rs->next()) {

			$omClass = ConsultaPeer::getOMClass();

			$cls = Propel::import($omClass);
			$obj1 = new $cls();
			$obj1->hydrate($rs);

			$omClass = DiagnosticoPeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj2  = new $cls();
			$obj2->hydrate($rs, $startcol2);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj2 = $temp_obj1->getDiagnostico(); 				if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
					$newObject = false;
					$temp_obj2->addConsulta($obj1);
					break;
				}
			}

			if ($newObject) {
				$obj2->initConsultas();
				$obj2->addConsulta($obj1);
			}

			$omClass = DatoEstudiantePeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj3  = new $cls();
			$obj3->hydrate($rs, $startcol3);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj3 = $temp_obj1->getDatoEstudiante(); 				if ($temp_obj3->getPrimaryKey() === $obj3->getPrimaryKey()) {
					$newObject = false;
					$temp_obj3->addConsulta($obj1);
					break;
				}
			}

			if ($newObject) {
				$obj3->initConsultas();
				$obj3->addConsulta($obj1);
			}

			$omClass = AteneausuarioPeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj4  = new $cls();
			$obj4->hydrate($rs, $startcol4);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj4 = $temp_obj1->getAteneausuario(); 				if ($temp_obj4->getPrimaryKey() === $obj4->getPrimaryKey()) {
					$newObject = false;
					$temp_obj4->addConsulta($obj1);
					break;
				}
			}

			if ($newObject) {
				$obj4->initConsultas();
				$obj4->addConsulta($obj1);
			}

			$omClass = TrastornoPeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj5  = new $cls();
			$obj5->hydrate($rs, $startcol5);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj5 = $temp_obj1->getTrastorno(); 				if ($temp_obj5->getPrimaryKey() === $obj5->getPrimaryKey()) {
					$newObject = false;
					$temp_obj5->addConsulta($obj1);
					break;
				}
			}

			if ($newObject) {
				$obj5->initConsultas();
				$obj5->addConsulta($obj1);
			}

			$omClass = HistoriaPsicologicaPeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj6  = new $cls();
			$obj6->hydrate($rs, $startcol6);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj6 = $temp_obj1->getHistoriaPsicologica(); 				if ($temp_obj6->getPrimaryKey() === $obj6->getPrimaryKey()) {
					$newObject = false;
					$temp_obj6->addConsulta($obj1);
					break;
				}
			}

			if ($newObject) {
				$obj6->initConsultas();
				$obj6->addConsulta($obj1);
			}

			$omClass = CitaPeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj7  = new $cls();
			$obj7->hydrate($rs, $startcol7);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj7 = $temp_obj1->getCita(); 				if ($temp_obj7->getPrimaryKey() === $obj7->getPrimaryKey()) {
					$newObject = false;
					$temp_obj7->addConsulta($obj1);
					break;
				}
			}

			if ($newObject) {
				$obj7->initConsultas();
				$obj7->addConsulta($obj1);
			}

			$results[] = $obj1;
		}
		return $results;
	}


	
	public static function doSelectJoinAllExceptTrastorno(Criteria $c, $con = null)
	{
		$c = clone $c;

								if ($c->getDbName() == Propel::getDefaultDB()) {
			$c->setDbName(self::DATABASE_NAME);
		}

		ConsultaPeer::addSelectColumns($c);
		$startcol2 = (ConsultaPeer::NUM_COLUMNS - ConsultaPeer::NUM_LAZY_LOAD_COLUMNS) + 1;

		DiagnosticoPeer::addSelectColumns($c);
		$startcol3 = $startcol2 + DiagnosticoPeer::NUM_COLUMNS;

		DatoEstudiantePeer::addSelectColumns($c);
		$startcol4 = $startcol3 + DatoEstudiantePeer::NUM_COLUMNS;

		AteneausuarioPeer::addSelectColumns($c);
		$startcol5 = $startcol4 + AteneausuarioPeer::NUM_COLUMNS;

		MotivoConsultaPeer::addSelectColumns($c);
		$startcol6 = $startcol5 + MotivoConsultaPeer::NUM_COLUMNS;

		HistoriaPsicologicaPeer::addSelectColumns($c);
		$startcol7 = $startcol6 + HistoriaPsicologicaPeer::NUM_COLUMNS;

		CitaPeer::addSelectColumns($c);
		$startcol8 = $startcol7 + CitaPeer::NUM_COLUMNS;

		$c->addJoin(ConsultaPeer::DIAGNOSTICO_ID, DiagnosticoPeer::ID);

		$c->addJoin(ConsultaPeer::ESTUDIANTE_ID, DatoEstudiantePeer::ID);

		$c->addJoin(ConsultaPeer::ENTREVISTADO_POR_ID, AteneausuarioPeer::ID);

		$c->addJoin(ConsultaPeer::MOTIVO_CONSULTA_ID, MotivoConsultaPeer::ID);

		$c->addJoin(ConsultaPeer::HIST_PSICOLOGICA_ID, HistoriaPsicologicaPeer::ID);

		$c->addJoin(ConsultaPeer::CITA_ID, CitaPeer::ID);


		$rs = BasePeer::doSelect($c, $con);
		$results = array();

		while($rs->next()) {

			$omClass = ConsultaPeer::getOMClass();

			$cls = Propel::import($omClass);
			$obj1 = new $cls();
			$obj1->hydrate($rs);

			$omClass = DiagnosticoPeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj2  = new $cls();
			$obj2->hydrate($rs, $startcol2);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj2 = $temp_obj1->getDiagnostico(); 				if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
					$newObject = false;
					$temp_obj2->addConsulta($obj1);
					break;
				}
			}

			if ($newObject) {
				$obj2->initConsultas();
				$obj2->addConsulta($obj1);
			}

			$omClass = DatoEstudiantePeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj3  = new $cls();
			$obj3->hydrate($rs, $startcol3);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj3 = $temp_obj1->getDatoEstudiante(); 				if ($temp_obj3->getPrimaryKey() === $obj3->getPrimaryKey()) {
					$newObject = false;
					$temp_obj3->addConsulta($obj1);
					break;
				}
			}

			if ($newObject) {
				$obj3->initConsultas();
				$obj3->addConsulta($obj1);
			}

			$omClass = AteneausuarioPeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj4  = new $cls();
			$obj4->hydrate($rs, $startcol4);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj4 = $temp_obj1->getAteneausuario(); 				if ($temp_obj4->getPrimaryKey() === $obj4->getPrimaryKey()) {
					$newObject = false;
					$temp_obj4->addConsulta($obj1);
					break;
				}
			}

			if ($newObject) {
				$obj4->initConsultas();
				$obj4->addConsulta($obj1);
			}

			$omClass = MotivoConsultaPeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj5  = new $cls();
			$obj5->hydrate($rs, $startcol5);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj5 = $temp_obj1->getMotivoConsulta(); 				if ($temp_obj5->getPrimaryKey() === $obj5->getPrimaryKey()) {
					$newObject = false;
					$temp_obj5->addConsulta($obj1);
					break;
				}
			}

			if ($newObject) {
				$obj5->initConsultas();
				$obj5->addConsulta($obj1);
			}

			$omClass = HistoriaPsicologicaPeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj6  = new $cls();
			$obj6->hydrate($rs, $startcol6);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj6 = $temp_obj1->getHistoriaPsicologica(); 				if ($temp_obj6->getPrimaryKey() === $obj6->getPrimaryKey()) {
					$newObject = false;
					$temp_obj6->addConsulta($obj1);
					break;
				}
			}

			if ($newObject) {
				$obj6->initConsultas();
				$obj6->addConsulta($obj1);
			}

			$omClass = CitaPeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj7  = new $cls();
			$obj7->hydrate($rs, $startcol7);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj7 = $temp_obj1->getCita(); 				if ($temp_obj7->getPrimaryKey() === $obj7->getPrimaryKey()) {
					$newObject = false;
					$temp_obj7->addConsulta($obj1);
					break;
				}
			}

			if ($newObject) {
				$obj7->initConsultas();
				$obj7->addConsulta($obj1);
			}

			$results[] = $obj1;
		}
		return $results;
	}


	
	public static function doSelectJoinAllExceptHistoriaPsicologica(Criteria $c, $con = null)
	{
		$c = clone $c;

								if ($c->getDbName() == Propel::getDefaultDB()) {
			$c->setDbName(self::DATABASE_NAME);
		}

		ConsultaPeer::addSelectColumns($c);
		$startcol2 = (ConsultaPeer::NUM_COLUMNS - ConsultaPeer::NUM_LAZY_LOAD_COLUMNS) + 1;

		DiagnosticoPeer::addSelectColumns($c);
		$startcol3 = $startcol2 + DiagnosticoPeer::NUM_COLUMNS;

		DatoEstudiantePeer::addSelectColumns($c);
		$startcol4 = $startcol3 + DatoEstudiantePeer::NUM_COLUMNS;

		AteneausuarioPeer::addSelectColumns($c);
		$startcol5 = $startcol4 + AteneausuarioPeer::NUM_COLUMNS;

		MotivoConsultaPeer::addSelectColumns($c);
		$startcol6 = $startcol5 + MotivoConsultaPeer::NUM_COLUMNS;

		TrastornoPeer::addSelectColumns($c);
		$startcol7 = $startcol6 + TrastornoPeer::NUM_COLUMNS;

		CitaPeer::addSelectColumns($c);
		$startcol8 = $startcol7 + CitaPeer::NUM_COLUMNS;

		$c->addJoin(ConsultaPeer::DIAGNOSTICO_ID, DiagnosticoPeer::ID);

		$c->addJoin(ConsultaPeer::ESTUDIANTE_ID, DatoEstudiantePeer::ID);

		$c->addJoin(ConsultaPeer::ENTREVISTADO_POR_ID, AteneausuarioPeer::ID);

		$c->addJoin(ConsultaPeer::MOTIVO_CONSULTA_ID, MotivoConsultaPeer::ID);

		$c->addJoin(ConsultaPeer::TRASTORNO_ID, TrastornoPeer::ID);

		$c->addJoin(ConsultaPeer::CITA_ID, CitaPeer::ID);


		$rs = BasePeer::doSelect($c, $con);
		$results = array();

		while($rs->next()) {

			$omClass = ConsultaPeer::getOMClass();

			$cls = Propel::import($omClass);
			$obj1 = new $cls();
			$obj1->hydrate($rs);

			$omClass = DiagnosticoPeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj2  = new $cls();
			$obj2->hydrate($rs, $startcol2);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj2 = $temp_obj1->getDiagnostico(); 				if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
					$newObject = false;
					$temp_obj2->addConsulta($obj1);
					break;
				}
			}

			if ($newObject) {
				$obj2->initConsultas();
				$obj2->addConsulta($obj1);
			}

			$omClass = DatoEstudiantePeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj3  = new $cls();
			$obj3->hydrate($rs, $startcol3);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj3 = $temp_obj1->getDatoEstudiante(); 				if ($temp_obj3->getPrimaryKey() === $obj3->getPrimaryKey()) {
					$newObject = false;
					$temp_obj3->addConsulta($obj1);
					break;
				}
			}

			if ($newObject) {
				$obj3->initConsultas();
				$obj3->addConsulta($obj1);
			}

			$omClass = AteneausuarioPeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj4  = new $cls();
			$obj4->hydrate($rs, $startcol4);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj4 = $temp_obj1->getAteneausuario(); 				if ($temp_obj4->getPrimaryKey() === $obj4->getPrimaryKey()) {
					$newObject = false;
					$temp_obj4->addConsulta($obj1);
					break;
				}
			}

			if ($newObject) {
				$obj4->initConsultas();
				$obj4->addConsulta($obj1);
			}

			$omClass = MotivoConsultaPeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj5  = new $cls();
			$obj5->hydrate($rs, $startcol5);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj5 = $temp_obj1->getMotivoConsulta(); 				if ($temp_obj5->getPrimaryKey() === $obj5->getPrimaryKey()) {
					$newObject = false;
					$temp_obj5->addConsulta($obj1);
					break;
				}
			}

			if ($newObject) {
				$obj5->initConsultas();
				$obj5->addConsulta($obj1);
			}

			$omClass = TrastornoPeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj6  = new $cls();
			$obj6->hydrate($rs, $startcol6);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj6 = $temp_obj1->getTrastorno(); 				if ($temp_obj6->getPrimaryKey() === $obj6->getPrimaryKey()) {
					$newObject = false;
					$temp_obj6->addConsulta($obj1);
					break;
				}
			}

			if ($newObject) {
				$obj6->initConsultas();
				$obj6->addConsulta($obj1);
			}

			$omClass = CitaPeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj7  = new $cls();
			$obj7->hydrate($rs, $startcol7);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj7 = $temp_obj1->getCita(); 				if ($temp_obj7->getPrimaryKey() === $obj7->getPrimaryKey()) {
					$newObject = false;
					$temp_obj7->addConsulta($obj1);
					break;
				}
			}

			if ($newObject) {
				$obj7->initConsultas();
				$obj7->addConsulta($obj1);
			}

			$results[] = $obj1;
		}
		return $results;
	}


	
	public static function doSelectJoinAllExceptCita(Criteria $c, $con = null)
	{
		$c = clone $c;

								if ($c->getDbName() == Propel::getDefaultDB()) {
			$c->setDbName(self::DATABASE_NAME);
		}

		ConsultaPeer::addSelectColumns($c);
		$startcol2 = (ConsultaPeer::NUM_COLUMNS - ConsultaPeer::NUM_LAZY_LOAD_COLUMNS) + 1;

		DiagnosticoPeer::addSelectColumns($c);
		$startcol3 = $startcol2 + DiagnosticoPeer::NUM_COLUMNS;

		DatoEstudiantePeer::addSelectColumns($c);
		$startcol4 = $startcol3 + DatoEstudiantePeer::NUM_COLUMNS;

		AteneausuarioPeer::addSelectColumns($c);
		$startcol5 = $startcol4 + AteneausuarioPeer::NUM_COLUMNS;

		MotivoConsultaPeer::addSelectColumns($c);
		$startcol6 = $startcol5 + MotivoConsultaPeer::NUM_COLUMNS;

		TrastornoPeer::addSelectColumns($c);
		$startcol7 = $startcol6 + TrastornoPeer::NUM_COLUMNS;

		HistoriaPsicologicaPeer::addSelectColumns($c);
		$startcol8 = $startcol7 + HistoriaPsicologicaPeer::NUM_COLUMNS;

		$c->addJoin(ConsultaPeer::DIAGNOSTICO_ID, DiagnosticoPeer::ID);

		$c->addJoin(ConsultaPeer::ESTUDIANTE_ID, DatoEstudiantePeer::ID);

		$c->addJoin(ConsultaPeer::ENTREVISTADO_POR_ID, AteneausuarioPeer::ID);

		$c->addJoin(ConsultaPeer::MOTIVO_CONSULTA_ID, MotivoConsultaPeer::ID);

		$c->addJoin(ConsultaPeer::TRASTORNO_ID, TrastornoPeer::ID);

		$c->addJoin(ConsultaPeer::HIST_PSICOLOGICA_ID, HistoriaPsicologicaPeer::ID);


		$rs = BasePeer::doSelect($c, $con);
		$results = array();

		while($rs->next()) {

			$omClass = ConsultaPeer::getOMClass();

			$cls = Propel::import($omClass);
			$obj1 = new $cls();
			$obj1->hydrate($rs);

			$omClass = DiagnosticoPeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj2  = new $cls();
			$obj2->hydrate($rs, $startcol2);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj2 = $temp_obj1->getDiagnostico(); 				if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
					$newObject = false;
					$temp_obj2->addConsulta($obj1);
					break;
				}
			}

			if ($newObject) {
				$obj2->initConsultas();
				$obj2->addConsulta($obj1);
			}

			$omClass = DatoEstudiantePeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj3  = new $cls();
			$obj3->hydrate($rs, $startcol3);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj3 = $temp_obj1->getDatoEstudiante(); 				if ($temp_obj3->getPrimaryKey() === $obj3->getPrimaryKey()) {
					$newObject = false;
					$temp_obj3->addConsulta($obj1);
					break;
				}
			}

			if ($newObject) {
				$obj3->initConsultas();
				$obj3->addConsulta($obj1);
			}

			$omClass = AteneausuarioPeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj4  = new $cls();
			$obj4->hydrate($rs, $startcol4);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj4 = $temp_obj1->getAteneausuario(); 				if ($temp_obj4->getPrimaryKey() === $obj4->getPrimaryKey()) {
					$newObject = false;
					$temp_obj4->addConsulta($obj1);
					break;
				}
			}

			if ($newObject) {
				$obj4->initConsultas();
				$obj4->addConsulta($obj1);
			}

			$omClass = MotivoConsultaPeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj5  = new $cls();
			$obj5->hydrate($rs, $startcol5);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj5 = $temp_obj1->getMotivoConsulta(); 				if ($temp_obj5->getPrimaryKey() === $obj5->getPrimaryKey()) {
					$newObject = false;
					$temp_obj5->addConsulta($obj1);
					break;
				}
			}

			if ($newObject) {
				$obj5->initConsultas();
				$obj5->addConsulta($obj1);
			}

			$omClass = TrastornoPeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj6  = new $cls();
			$obj6->hydrate($rs, $startcol6);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj6 = $temp_obj1->getTrastorno(); 				if ($temp_obj6->getPrimaryKey() === $obj6->getPrimaryKey()) {
					$newObject = false;
					$temp_obj6->addConsulta($obj1);
					break;
				}
			}

			if ($newObject) {
				$obj6->initConsultas();
				$obj6->addConsulta($obj1);
			}

			$omClass = HistoriaPsicologicaPeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj7  = new $cls();
			$obj7->hydrate($rs, $startcol7);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj7 = $temp_obj1->getHistoriaPsicologica(); 				if ($temp_obj7->getPrimaryKey() === $obj7->getPrimaryKey()) {
					$newObject = false;
					$temp_obj7->addConsulta($obj1);
					break;
				}
			}

			if ($newObject) {
				$obj7->initConsultas();
				$obj7->addConsulta($obj1);
			}

			$results[] = $obj1;
		}
		return $results;
	}

	
	public static function getTableMap()
	{
		return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
	}

	
	public static function getOMClass()
	{
		return ConsultaPeer::CLASS_DEFAULT;
	}

	
	public static function doInsert($values, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		if ($values instanceof Criteria) {
			$criteria = clone $values; 		} else {
			$criteria = $values->buildCriteria(); 		}

		$criteria->remove(ConsultaPeer::ID); 

				$criteria->setDbName(self::DATABASE_NAME);

		try {
									$con->begin();
			$pk = BasePeer::doInsert($criteria, $con);
			$con->commit();
		} catch(PropelException $e) {
			$con->rollback();
			throw $e;
		}

		return $pk;
	}

	
	public static function doUpdate($values, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		$selectCriteria = new Criteria(self::DATABASE_NAME);

		if ($values instanceof Criteria) {
			$criteria = clone $values; 
			$comparison = $criteria->getComparison(ConsultaPeer::ID);
			$selectCriteria->add(ConsultaPeer::ID, $criteria->remove(ConsultaPeer::ID), $comparison);

		} else { 			$criteria = $values->buildCriteria(); 			$selectCriteria = $values->buildPkeyCriteria(); 		}

				$criteria->setDbName(self::DATABASE_NAME);

		return BasePeer::doUpdate($selectCriteria, $criteria, $con);
	}

	
	public static function doDeleteAll($con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}
		$affectedRows = 0; 		try {
									$con->begin();
			$affectedRows += BasePeer::doDeleteAll(ConsultaPeer::TABLE_NAME, $con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	 public static function doDelete($values, $con = null)
	 {
		if ($con === null) {
			$con = Propel::getConnection(ConsultaPeer::DATABASE_NAME);
		}

		if ($values instanceof Criteria) {
			$criteria = clone $values; 		} elseif ($values instanceof Consulta) {

			$criteria = $values->buildPkeyCriteria();
		} else {
						$criteria = new Criteria(self::DATABASE_NAME);
			$criteria->add(ConsultaPeer::ID, (array) $values, Criteria::IN);
		}

				$criteria->setDbName(self::DATABASE_NAME);

		$affectedRows = 0; 
		try {
									$con->begin();
			
			$affectedRows += BasePeer::doDelete($criteria, $con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	public static function doValidate(Consulta $obj, $cols = null)
	{
		$columns = array();

		if ($cols) {
			$dbMap = Propel::getDatabaseMap(ConsultaPeer::DATABASE_NAME);
			$tableMap = $dbMap->getTable(ConsultaPeer::TABLE_NAME);

			if (! is_array($cols)) {
				$cols = array($cols);
			}

			foreach($cols as $colName) {
				if ($tableMap->containsColumn($colName)) {
					$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
					$columns[$colName] = $obj->$get();
				}
			}
		} else {

		}

		$res =  BasePeer::doValidate(ConsultaPeer::DATABASE_NAME, ConsultaPeer::TABLE_NAME, $columns);
    if ($res !== true) {
        $request = sfContext::getInstance()->getRequest();
        foreach ($res as $failed) {
            $col = ConsultaPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
            $request->setError($col, $failed->getMessage());
        }
    }

    return $res;
	}

	
	public static function retrieveByPK($pk, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		$criteria = new Criteria(ConsultaPeer::DATABASE_NAME);

		$criteria->add(ConsultaPeer::ID, $pk);


		$v = ConsultaPeer::doSelect($criteria, $con);

		return !empty($v) > 0 ? $v[0] : null;
	}

	
	public static function retrieveByPKs($pks, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		$objs = null;
		if (empty($pks)) {
			$objs = array();
		} else {
			$criteria = new Criteria();
			$criteria->add(ConsultaPeer::ID, $pks, Criteria::IN);
			$objs = ConsultaPeer::doSelect($criteria, $con);
		}
		return $objs;
	}

} 
if (Propel::isInit()) {
			try {
		BaseConsultaPeer::getMapBuilder();
	} catch (Exception $e) {
		Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
	}
} else {
			require_once 'lib/model/map/ConsultaMapBuilder.php';
	Propel::registerMapBuilder('lib.model.map.ConsultaMapBuilder');
}
